package org.apache.qpid.management.common.sasl;

import de.measite.smack.Sasl;
import java.util.Map;
import org.apache.harmony.javax.security.auth.callback.CallbackHandler;
import org.apache.harmony.javax.security.sasl.SaslClient;
import org.apache.harmony.javax.security.sasl.SaslClientFactory;
import org.apache.harmony.javax.security.sasl.SaslException;

public class CRAMMD5HashedSaslClientFactory
  implements SaslClientFactory
{
  public static final String MECHANISM = "CRAM-MD5-HASHED";

  public SaslClient createSaslClient(String[] paramArrayOfString, String paramString1, String paramString2, String paramString3, Map<String, ?> paramMap, CallbackHandler paramCallbackHandler)
    throws SaslException
  {
    int i = 0;
    while (true)
    {
      SaslClient localSaslClient;
      if (i >= paramArrayOfString.length)
        localSaslClient = null;
      while (true)
      {
        return localSaslClient;
        if (!(paramArrayOfString[i].equals("CRAM-MD5-HASHED")))
          break;
        if (paramCallbackHandler == null)
          throw new SaslException("CallbackHandler must not be null");
        String[] arrayOfString = new String[1];
        arrayOfString[0] = "CRAM-MD5";
        localSaslClient = Sasl.createSaslClient(arrayOfString, paramString1, paramString2, paramString3, paramMap, paramCallbackHandler);
      }
      ++i;
    }
  }

  public String[] getMechanismNames(Map paramMap)
  {
    String[] arrayOfString = new String[1];
    arrayOfString[0] = "CRAM-MD5-HASHED";
    return arrayOfString;
  }
}